var store,grid,row=-1;

Ext.onReady(function(){
	//产品规格
	var productSize = new Ext.form.ComboBox({
   		allowBlank: false,
        typeAhead: true,
        triggerAction: 'all',
        transform:'pn',
        lazyRender:true,
        listClass: 'x-combo-list-small'
    });
	
	// 开始和结束时间
	var dt = new Date();
	var time = dt.format('Y-m-d');
	var dateBegin = new Ext.form.TextField({
	    name: 'starttime',
	    id: 'starttime',
	    width: 100,
	    readOnly: true,
	    //value:time,
	    listeners:{
			'render':function(){
		       Ext.EventManager.on("starttime", 'click', function(){
		           new  WdatePicker({
		                skin: 'ext',                            // 应用ext的皮肤样式
		                dateFmt: 'yyyy-MM-dd'                   // 格式为：年-月
		             });
		      })
	  		}
		}
	});
	   var dateEnd = new Ext.form.TextField({
	    name: 'endtime',
	    id: 'endtime',
	    width: 100,
	    readOnly: true,
	    value:time,
	    listeners:{
		   'render':function(){
		       Ext.EventManager.on("endtime", 'click', function(){
		           new  WdatePicker({
		                skin: 'ext',                            // 应用ext的皮肤样式
		                dateFmt: 'yyyy-MM-dd'                   // 格式为：年-月
		             });
		      })
	   		}
	   }
	});
	// 查询条件Bar
	 var tbar = new Ext.Toolbar({
		 scope:this,height:25,items:['产品规格:',productSize,
	      '-','开始时间:',dateBegin,'-','结束时间:',dateEnd,
	      '-',{ 
	         text:'查询',
		    	 pressed: true,
				 handler:function()
				 {
					 Ext.Ajax.request({
						   url: rootPath+'/product/productStatisByType.do',
						   success: function(response,options){
							   var myChart = new FusionCharts( "../common/FusionCharts/MSLine.swf", "myChartId", "800", "600", "0", "1" );
							   var dataXml = '<chart caption="规格销售统计"showvalues="1">'
							   							+ response.responseText + '</chart>';
							    myChart.setDataXML(dataXml);
							    myChart.render("chartContainer");
						   },
						   failure: function(){
							   alert('请求失败，稍后再试试看？');
						   },
						   params: { 'product.productCode': productSize.getValue(),startTime:dateBegin.getValue(),endTime:dateEnd.getValue()}
						});
				 }
		 	}]
	});

    var addform=new Ext.form.FormPanel({
    	url:'dws!add.do',
    	id:'addform',
    	height:30,
   		usepurse:'addform', //用途,默认情况下是添加，也可以是modifyform
   		labelWidth:65,labelAlign:'right',
       	baseCls:"x-plain",style:"padding:5px",
       	renderTo:'formpanel',
        tbar:tbar
    });
    
    addform.render();
});